package com.joinway.framework.admin.core.chart.constant;

import org.apache.commons.lang3.StringUtils;

import com.joinway.framework.bean.domain.constant.DomainConstants;

public final class SqlClauseFactory {

	public static String createPushLogHistoryQuery(){
		String selectClause = StringUtils.join(
		"select * from ( "
		, "	select pl.* "
		, "			, if(sub.un_accept_count is null, if(pl.target = '" , DomainConstants.PushTarget.Mass, "', 0, sub.un_accept_count), sub.un_accept_count) un_accept_count"
		, "		from push_log pl "
		, "			left join ( "
		, "				select page_id, count(status) un_accept_count " 
		, "					from user_notice_log where status = '$DomainConstants.NO'" 
		, "				group by page_id "
		, "			) sub "
		, "		on pl.page_id = sub.page_id "
		, ") pvt "
		);	
		
		return selectClause;
	}
	
	private SqlClauseFactory(){}
	
}
